package cn.iocoder.yudao.module.jifenyuan.controller.admin.roomuserbind;

import cn.iocoder.yudao.module.jifenyuan.controller.app.roomuserbind.vo.AppRoomUserBindRespVO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.jifenyuan.controller.admin.roomuserbind.vo.*;
import cn.iocoder.yudao.module.jifenyuan.dal.dataobject.roomuserbind.RoomUserBindDO;
import cn.iocoder.yudao.module.jifenyuan.convert.roomuserbind.RoomUserBindConvert;
import cn.iocoder.yudao.module.jifenyuan.service.roomuserbind.RoomUserBindService;

@Tag(name = "管理后台 - 记分员 房间与成员绑定")
@RestController
@RequestMapping("/jifenyuan/room-user-bind")
@Validated
public class RoomUserBindController {

    @Resource
    private RoomUserBindService roomUserBindService;

    @PostMapping("/create")
    @Operation(summary = "创建记分员 房间与成员绑定")
    @PreAuthorize("@ss.hasPermission('jifenyuan:room-user-bind:create')")
    public CommonResult<Long> createRoomUserBind(@Valid @RequestBody RoomUserBindCreateReqVO createReqVO) {
        return success(roomUserBindService.createRoomUserBind(RoomUserBindConvert.INSTANCE.convert(createReqVO)));
    }

    @PutMapping("/update")
    @Operation(summary = "更新记分员 房间与成员绑定")
    @PreAuthorize("@ss.hasPermission('jifenyuan:room-user-bind:update')")
    public CommonResult<Boolean> updateRoomUserBind(@Valid @RequestBody RoomUserBindUpdateReqVO updateReqVO) {
        roomUserBindService.updateRoomUserBind(RoomUserBindConvert.INSTANCE.convert(updateReqVO));
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除记分员 房间与成员绑定")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('jifenyuan:room-user-bind:delete')")
    public CommonResult<Boolean> deleteRoomUserBind(@RequestParam("id") Long id) {
        roomUserBindService.deleteRoomUserBind(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得记分员 房间与成员绑定")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('jifenyuan:room-user-bind:query')")
    public CommonResult<AppRoomUserBindRespVO> getRoomUserBind(@RequestParam("id") Long id) {
        RoomUserBindDO roomUserBind = roomUserBindService.getRoomUserBind(id);
        return success(RoomUserBindConvert.INSTANCE.convert(roomUserBind));
    }

    @GetMapping("/list")
    @Operation(summary = "获得记分员 房间与成员绑定列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    @PreAuthorize("@ss.hasPermission('jifenyuan:room-user-bind:query')")
    public CommonResult<List<AppRoomUserBindRespVO>> getRoomUserBindList(@RequestParam("ids") Collection<Long> ids) {
        List<RoomUserBindDO> list = roomUserBindService.getRoomUserBindList(ids);
        return success(RoomUserBindConvert.INSTANCE.convertList(list));
    }

//    @GetMapping("/page")
//    @Operation(summary = "获得记分员 房间与成员绑定分页")
//    @PreAuthorize("@ss.hasPermission('jifenyuan:room-user-bind:query')")
//    public CommonResult<PageResult<AppRoomUserBindRespVO>> getRoomUserBindPage(@Valid RoomUserBindPageReqVO pageVO) {
//        PageResult<RoomUserBindDO> pageResult = roomUserBindService.getRoomUserBindPage(RoomUserBindConvert.INSTANCE.convert(pageVO));
//        return success(RoomUserBindConvert.INSTANCE.convertPage(pageResult));
//    }



}
